package com.cssnj.portal.web.query;

import com.cssnj.portal.domain.common.UserInfo;
import com.cssnj.portal.service.query.Query17Service;
import io.predictech.framework.domain.common.JsonRequest;
import io.predictech.framework.domain.common.JsonResponse;
import io.predictech.framework.domain.exception.BaseException;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;

@Controller
@RequestMapping("/query/query17")
public class Query17Controler {
    @Autowired
    private Query17Service query17Service;

    @RequestMapping({"/init.do"})
    public ModelAndView init(HttpServletRequest request) throws BaseException, SQLException {
        ModelAndView modelAndView = new ModelAndView("query/query17");
        return modelAndView;
    }

    @RequestMapping({"/queryData.do"})
    @ResponseBody
    public JsonResponse queryData(HttpServletRequest request) throws BaseException, SQLException {
        JsonRequest jsonRequest = new JsonRequest();
        UserInfo userInfo = (UserInfo) SecurityUtils.getSubject().getPrincipal();
        String swjgdm = userInfo.getCxjgDm();
        jsonRequest.setServiceName("query17Service");
        jsonRequest.setHandleCode("queryData");
        jsonRequest.getReqData().put("swjgdm", swjgdm);
        JsonResponse jsonResponse = query17Service.execute(jsonRequest);
        return jsonResponse;
    }
}
